<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

    <link href="./static/plugins/bootstrap/bootstrap.min.css" rel="stylesheet">
    <link href="./static/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">
    <link href="./static/css/font-awesome.min.css" rel="stylesheet">
    <link href="./static/plugins/toastr/toastr.min.css" rel="stylesheet">
    <link href="./static/plugins/blueimp/blueimp-gallery.min.css" rel="stylesheet">
    <link href="./static/plugins/ladda/ladda-themeless.min.css" rel="stylesheet">
    <link href="./static/css/animate.css" rel="stylesheet">
    <link href="./static/css/style.css" rel="stylesheet">

    <script type="text/javascript" src="./static/js/jquery-3.1.1.min.js"></script>
    <script type="text/javascript" src="./static/plugins/bootstrap/bootstrap.min.js"></script>
</head>
<body class="fixed-sidebar no-skin-config full-height-layout">
<div id="wrapper" v-cloak>
    <nav class="navbar-default navbar-static-side" role="navigation">
        <div class="sidebar-collapse">
            <ul class="nav metismenu" id="side-menu">
                <li class="nav-header">
                    <div class="dropdown profile-element">
                        <span class="img-thumb"><strong class="font-bold">{{user.company}}</strong></span>
                        <a href="javascript:">
                            <span class="clear">
                                <span class="block m-t-xs"> <strong class="font-bold">{{type[user.type]}}</strong></span>
                            </span>
                        </a>
                    </div>
                </li>
                <li>
                    <a href="/home.html"><i class="fa fa-home"></i> <span class="nav-label">个人中心</span></a>
                </li>
                <li>
                    <a href="#"><i class="fa fa-info-circle"></i> <span class="nav-label">基本信息</span><span class="fa arrow"></span></a>
                    <ul class="nav nav-second-level collapse">
                        <li><a href="user.html">个人信息</a></li>
                        <li><a href="verify.html">账号认证</a></li>
                        <li><a href="finance.html">财务明细</a></li>
                        <li v-if="user.is_root>0"><a href="employee.html">员工账号</a></li>
                        <li><a href="pwd.html">修改密码</a></li>
                        <li><a href="address.html">收货地址</a></li>
                    </ul>
                </li>
                <li v-if="user.type!=2">
                    <a href="#"><i class="fa fa-th-large"></i> <span class="nav-label">询价</span> <span class="fa arrow"></span></a>
                    <ul class="nav nav-second-level collapse">
                        <li><a href="inquiry_list.html">询价单</a></li>
                        <li><a href="enquiry.html">我要询价</a></li>
                    </ul>
                </li>
                <li v-else>
                    <a href="#"><i class="fa fa-th-large"></i> <span class="nav-label">报价</span> <span class="fa arrow"></span></a>
                    <ul class="nav nav-second-level collapse">
                        <li><a href="inquiry_list_supply.html">未报价</a></li>
                        <li><a href="offer_sheet.html">已报价</a></li>
                    </ul>
                </li>
                <li class="active">
                    <a href="index.html"><i class="fa fa-first-order"></i> <span class="nav-label">订单管理</span> <span class="fa arrow"></span></a>
                    <ul class="nav nav-second-level collapse">
                        <li class="active"><a href="order_list.html">订单列表</a></li>

                    </ul>
                </li>
                <li>
                    <a onclick="logout()"><i class="fa fa-sign-out"></i> <span class="nav-label">退出登录</span></a>
                </li>
            </ul>
        </div>
    </nav>
    <div id="page-wrapper" class="gray-bg">
        <div class="row border-bottom">
            <nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0">
                <div class="navbar-header">
                    <a class="navbar-minimalize minimalize-styl-2 btn btn-success" href="#"><i class="fa fa-bars"></i> </a>
                </div>
                <ul class="nav navbar-top-links navbar-right">
                    <li class="m-r">
                        <span class="m-r-sm text-danger font-bold welcome-message" id="nav-title">{{user.name}}&nbsp;</span><span>{{user.company}}&nbsp;{{user.zone}}</span>
                    </li>
                    <li class="dropdown m-r">
                        <a class="dropdown-toggle count-info" data-toggle="dropdown" href="#" aria-expanded="false">
                            <i class="fa fa-bell"></i> <span class="label label-danger" v-if="msgbox.total">{{msgbox.total}}</span>
                        </a>
                        <ul class="dropdown-menu dropdown-alerts">
                            <li v-if="msgbox.daifahuo">
                                <a href="javascript:parent.document.getElementById('main').src='order_list.html?order_status=200'">
                                    <div>
                                        <i class="fa fa-envelope fa-fw"></i> 您有<strong>{{msgbox.daifahuo}}</strong>个待发货订单
                                    </div>
                                </a>
                            </li>
                            <li class="divider" v-if="msgbox.daifahuo"></li>
                            <li v-if="msgbox.daifukuan">
                                <a href="javascript:parent.document.getElementById('main').src='order_list.html?order_status=100'">
                                    <div>
                                        <i class="fa fa-twitter fa-fw"></i> 您有<strong>{{msgbox.daifukuan}}</strong>个待付款订单
                                    </div>
                                </a>
                            </li>
                            <li class="divider" v-if="msgbox.daifukuan"></li>
                            <li v-if="msgbox.daishouhuo">
                                <a href="javascript:parent.document.getElementById('main').src='order_list.html?order_status=300'">
                                    <div>
                                        <i class="fa fa-twitter fa-fw"></i> 您有<strong>{{msgbox.daishouhuo}}</strong>个订单待收货
                                    </div>
                                </a>
                            </li>
                            <li class="divider" v-if="msgbox.daishouhuo"></li>
                            <li v-if="msgbox.baojiazhong && user.type==1">
                                <a href="javascript:parent.document.getElementById('main').src='inquiry_list.html?status=100'">
                                    <div>
                                        <i class="fa fa-twitter fa-fw"></i> 您有<strong>{{msgbox.baojiazhong}}</strong>个报价中询价单
                                    </div>
                                </a>
                            </li>
                            <li class="divider" v-if="msgbox.baojiazhong && user.type==1"></li>
                            <li v-if="msgbox.daibaojia">
                                <a href="javascript:parent.document.getElementById('main').src='inquiry_list_supply.html'">
                                    <div>
                                        <i class="fa fa-twitter fa-fw"></i> 您有<strong>{{msgbox.daibaojia}}</strong>个待报价询价单
                                    </div>
                                </a>
                            </li>
                            <li class="divider" v-if="msgbox.daibaojia"></li>
                            <li v-if="msgbox.weitongguo">
                                <a href="javascript:parent.document.getElementById('main').src='offer_sheet.html'">
                                    <div>
                                        <i class="fa fa-twitter fa-fw"></i> 您有<strong>{{msgbox.weitongguo}}</strong>个报价未通过
                                    </div>
                                </a>
                            </li>
                        </ul>
                    </li>
                    <li>
                        <a onclick="logout()">
                            <i class="fa fa-sign-out"></i> 安全退出
                        </a>
                    </li>
                </ul>
            </nav>
        </div>
        <!--面包屑-->
        <div class="row wrapper border-bottom white-bg p-h-sm">
            <div class="col-lg-10">
                <ol class="breadcrumb">
                    <li class="active">订单管理</li>
                    <li class="active"><strong>订单详情</strong></li>
                </ol>
            </div>
        </div>

        <div class="wrapper wrapper-content animated fadeInRight tooltip-demo">
            <div class="row">
                <div class="ibox-content m-b-sm border-bottom">
                    <div class="col-sm-1"><a href="order_list.html" class="btn btn-danger btn-outline btn-sm" id="back"><i class="fa fa-mail-reply-all text-5 fa-return"></i>&nbsp;返回</a></div>
                    <div class="clearfix"></div>
                </div>
            </div>

            <div class="row">
                <div class="ibox">
                    <div class="ibox-content">
                        <div class="col-lg-5">
                            <dl class="dl-horizontal">

                                <dt>询价公司 :</dt>
                                <dd v-if="order.company">{{order.company.name}} ({{order.company.zone}})</dd>
                                <dt>联系人 :</dt>
                                <dd v-if="order.member">{{order.member.name}}</dd>
                                <dt>联系电话 :</dt>
                                <dd v-if="order.member">{{order.member.phone}}</dd>
                                <dt>订单编号 :</dt>
                                <dd>{{order.order_no}}</dd>
                                <dt>下单时间 :</dt>
                                <dd>{{order.created_at}}</dd>
                                <dt>订单金额 :</dt>
                                <dd><i class="fa fa-cny"></i>&nbsp;<strong>{{order.fee}}</strong></dd>
                                <dt>订单状态 :</dt>
                                <dd class="text-navy">{{status[order.status]}}</dd>
                                <dt>买家备注 :</dt>
                                <dd class="text-danger">{{order.remark}}</dd>
                            </dl>
                        </div>

                        <div class="col-lg-7" id="cluster_info">
                            <dl class="dl-horizontal">
                                <dt>收货人 :</dt>
                                <dd>{{order.shipping_name}}</dd>
                                <dt>联系电话 :</dt>
                                <dd>{{order.shipping_phone}}</dd>
                                <dt>收货地址 :</dt>
                                <dd class="">{{order.shipping_zone}}&nbsp;{{order.shipping_addr}}</dd>
                            </dl>
                        </div>
                        <div class="clearfix"></div>
                    </div>
                </div>
            </div>

            <div class="row">
                <div class="ibox">
                    <div class="table-responsive ibox-content">
                        <table class="table invoice-table table-hover">
                            <thead>
                            <tr>
                                <th>零件</th>
                                <th>OE码</th>
                                <th>品质</th>
                                <th>单价</th>
                                <th>数量</th>
                                <th>小计</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr v-for="(vg,idx) in order.goods">
                                <td class="text-center"><strong>{{vg.name}}</strong></td>
                                <td class="text-center">{{vg.oecode}}</td>
                                <td class="text-center">{{vg.quality}}</td>
                                <td class="text-center">{{vg.price}}</td>
                                <td class="text-center">{{vg.num}}</td>
                                <td class="text-center">{{vg.price*vg.num}}</td>
                            </tr>
                            </tbody>
                        </table>
                        <table class="table invoice-total">
                            <tbody>
                            <tr>
                                <td><strong>订单金额 :</strong></td>
                                <td><i class="fa fa-cny"></i>&nbsp;{{order.fee}}</td>
                            </tr>
                            </tbody>
                        </table>
                    </div>

                    <div class="ibox-footer text-right">
                        <button class="ladda-button btn btn-success btn-w-m btn-sm" type="button" data-toggle="modal" data-target="#send-modal" v-if="order.delivery_status==0">发货</button>
                    </div>
                </div>
            </div>

            <div class="row" v-if="order.status==300 || order.status==400">
                <div class="ibox">
                    <div class="ibox-content">
                        <h3>物流信息 :</h3>
                        <div class="col-md-4">
                            <table class="table table-hover">
                                <tbody>
                                <tr>
                                    <th>物流公司 :</th>
                                    <td style="text-align: left">{{order.delivery_company}}</td>
                                </tr>
                                <tr>
                                    <th>物流单号 :</th>
                                    <td style="text-align: left">{{order.delivery_no}}</td>
                                </tr>
                                <tr>
                                    <th>发货备注 :</th>
                                    <td style="text-align: left">{{order.delivery_remark}}</td>
                                </tr>
                                <tr>
                                    <th>发货单图片 :</th>
                                    <td style="text-align: left">
                                        <div class="lightBoxGallery links text-left img-100 bj">
                                            <a v-for="(vo,index) in order.delivery_imgs" :href="vo"><img :src="vo"></a>
                                        </div>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                        <div class="clearfix"></div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="modal inmodal fade" id="send-modal" tabindex="-1" role="dialog" aria-hidden="true" data-backdrop="static" data-keyboard="false">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title">填写发货信息</h4>
                    <small class="text-navy">请上传发货单,或者手工填写物流公司/物流单号</small>
                </div>
                <div class="modal-body">
                    <form id="send-form">
                        <div class="form-group"><label>物流公司</label> <input type="text" placeholder="请填写物流公司" id="delivery_company" class="form-control"></div>
                        <div class="form-group"><label>物流单号</label> <input type="text" placeholder="请填写物流单号" id="delivery_no" class="form-control"></div>
                        <div class="form-group">
                            <label>上传发货单</label>
                            <div class="clearfix"></div>

                            <div class="img-list car-img" v-for="(vo,index) in imgs">
                                <div class="img-del">
                                    <i class="fa fa-trash pointer" @click="delItem(index)"></i>
                                </div>
                                <img :src="vo">
                            </div>
                            <div class="img-list">
                                <input type="file" multiple class="hide-input" id="imgs" title="点击上传">
                                <img src="http://image.hngpmall.com//upload/image/20190715/1563160710542909856.jpg">
                            </div>

                            <div class="clearfix"></div>
                        </div>
                        <div class="form-group"><label>发货备注</label>
                            <textarea placeholder="请填写发货备注" id="remark" class="form-control"></textarea>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" @click="sendGoods()">确认</button>
                </div>
            </div>
        </div>
    </div>

    <div id="blueimp-gallery" class="blueimp-gallery">
        <div class="slides"></div>
        <h3 class="title"></h3>
        <a class="prev">‹</a>
        <a class="next">›</a>
        <a class="close">×</a>
        <a class="play-pause"></a>
        <ol class="indicator"></ol>
    </div>
</div>

<script type="text/javascript" src="./static/plugins/toastr/toastr.min.js"></script>
<script type="text/javascript" src="./static/plugins/validate/jquery.validate.min.js"></script>
<script type="text/javascript" src="./static/js/slimscroll.min.js"></script>
<script type="text/javascript" src="./static/js/metisMenu.js"></script>
<script type="text/javascript" src="./static/js/inspinia.js"></script>
<script type="text/javascript" src="./static/plugins/blueimp/jquery.blueimp-gallery.min.js"></script>
<script type="text/javascript" src="./static/plugins/ladda/spin.min.js"></script>
<script type="text/javascript" src="./static/plugins/ladda/ladda.min.js"></script>
<script type="text/javascript" src="./static/plugins/ladda/ladda.jquery.min.js"></script>
<script type="text/javascript" src="./static/js/vue.min.js"></script>
<script type="text/javascript" src="./static/js/qiniu.min.js"></script>
<script type="text/javascript" src="./static/js/main.js"></script>
<script>
    var vm = new Vue({
        el: '#wrapper',
        data: {
            user: {},
            order: {},
            token: '',
            imgs: [],
            status: {"100": "待支付", "200": "已支付、待发货", "300": "已发货", "400": "已收货,订单完成", "500": "已取消"},
            type: {"1": "修理厂", "2": "配件商", "3": "保险公司"},
            msgbox: {},
        },
        methods: {
            getData: function (instance) {
                var url = api + 'user/ordersDetail';
                if (instance.user.type == 2) {
                    url = api + 'provider/ordersDetail';
                }
                $.ajax({
                    type: 'POST',
                    url: url,
                    data: {order_no: getUrlParam('order_no')},
                    success: function (data) {
                        checkToken(data);
                        if (data.ret == 0) {
                            instance.order = data.data;
                            if (data.data.status == 300 || data.data.status == 400) {
                                setTimeout(function () {
                                    $('.links').on('click', function (event) {
                                        event = event || window.event;
                                        var target = event.target || event.srcElement,
                                            link = target.src ? target.parentNode : target,
                                            options = {index: link, event: event},
                                            links = this.getElementsByTagName('a');
                                        blueimp.Gallery(links, options);
                                    });
                                }, 100);
                            }
                        }
                    }
                });
            },
            delItem: function (index) {
                vm.imgs.splice(index, 1);
            },
            sendGoods: function (order_id) {
                var delivery_company = document.getElementById('delivery_company').value;
                var delivery_no = document.getElementById('delivery_no').value;
                if (vm.imgs.length == 0) {
                    if (!delivery_company) {
                        toastr.warning('请填写物流公司');
                        return;
                    }
                    if (!delivery_no) {
                        toastr.warning('请填写物流单号');
                        return;
                    }
                }

                var param = {
                    orders_id: vm.order.orders_id,
                    provider_id: vm.order.provider_id,
                    delivery_company: delivery_company,
                    delivery_no: delivery_no,
                    delivery_imgs: vm.imgs,
                    delivery_remark: document.getElementById('remark').value
                };
                var btn = $(event.currentTarget).ladda().ladda('start');
                $.ajax({
                    type: 'POST',
                    url: api + 'provider/confirmDelivery',
                    data: param,
                    success: function (data) {
                        btn.ladda('stop');
                        checkToken(data);
                        if (data.ret == 0) {
                            parent.socket.send(JSON.stringify({action: "delivery", wsmem: data.data.wsmem, order_no: vm.order.order_no, orders_id: data.data.orders_id}));
                            toastr.success('操作成功');
                            vm.getData(vm);
                            $('#send-modal').modal('hide');
                        }
                    }
                });
            }
        },
        created: function () {
            this.user = getItem('info');
            this.getData(this);
            var instance = this;
            $.ajax({
                type: 'POST',
                url: api + '/index/uptoken',
                success: function (data) {
                    instance.token = data.uptoken;
                }
            });
            $.ajax({
                type: 'POST',
                url: api + 'user/msgNum',
                dataType: 'json',
                success: function (data) {
                    if (data.ret == 0) {
                        instance.msgbox = data.data;
                    }
                },
            });
        },
        mounted: function () {
            var instance = this;
            $('#send-modal').on('hidden.bs.modal', function () {
                instance.imgs = [];
                document.getElementById('send-form').reset();
            });
            $('#imgs').on('change', function () {
                var files = this.files;
                for (var i = 0; i < files.length; i++) {
                    qiniu_upload(files[i], instance.token, function (res) {
                        instance.imgs.push(cdn + res.key);
                        if (i == files.length) {
                            $('.loading-spiner').addClass('hidden');
                        }
                    });
                }
            });
        }
    });

</script>
</body>
</html>
